package www.lagou.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import www.lagou.entity.Employee;
import www.lagou.utils.DruidUtils;

import java.sql.SQLException;
import java.util.List;

public class EmployeeDao {

    // 查询所有的员工信息 (不包含没有部门的员工)。
    public List<Employee> findEmplyeeByDidNoNull() throws SQLException {

        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());

        String sql = "select * from employee where did is not null";

        List<Employee> query = qr.query(sql, new BeanListHandler<>(Employee.class));

        return query;
    }

}
